home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / LEVEL1 / TNC2.AS < prev    next >
Text File  |  1990-11-14  |  9KB  |  286 lines

  1. ;/*
  2. ; * Copyright 1988 by the Radio Amateur Telecommunications Society
  3. ; * and Thomas A. Moulton, W2VY
  4. ; *
  5. ; * This software may only be modified, copied, distributed or
  6. ; * executed for non-profit purposes by individuals operating
  7. ; * systems in the Amateur Radio Service.  Credit to the
  8. ; * author(s) and to the Radio Amateur Telecommunications Society
  9. ; * must be made in modules where RATS provided software is used,
  10. ; * and in any announcements and documentation.  
  11. ; *
  12. ; * As a non-profit, research and development organization,  the
  13. ; * Radio Amateur Telecommunications Society distributes software
  14. ; * in both executable and source forms.  This policy is in place
  15. ; * to encourage the development and distribution of OSI-based,
  16. ; * networking tools.  In order to protect the interests of the
  17. ; * Society and the authors, we have placed some conditions
  18. ; * of use on the software.  Other groups are encouraged
  19. ; * to place the same or similar guidelines on
  20. ; * software they produce.
  21. ; *
  22. ; * The Radio Amateur Telecommunications Society reserves the right
  23. ; * to specify and alter the terms under which software provided by
  24. ; * the Society may be used.  This policy is consistent with the 
  25. ; * objective of uniform and consistent "Open Systems Interconnections."
  26. ; * 
  27. ; * All acceptable Amateur Radio related uses of this software
  28. ; * will be outlined in the "ROSE Implementer's Guide".  Individuals
  29. ; * or organizations wishing to add to, or modify the provisions of
  30. ; * the guide to accommodate local or evolutionary requirements
  31. ; * should document the proposed change(s) and forward them to the
  32. ; * Society.  If accepted, written notification will be provided by
  33. ; * the Society to the submitting organization or individual(s).
  34. ; * The Society will then issue a "ROSE Implementer's Guide Change
  35. ; * Notice".  Periodically, the Society will re-issue the "ROSE 
  36. ; * Implementer's Guide" and incorporate the text of the change 
  37. ; * notices.  This procedure has been put in to place to ensure
  38. ; * compatibility between systems and to ensure their "Openness"
  39. ; * and interoperability.
  40. ; *
  41. ; * No part of this software may be used in other packages 
  42. ; * without prior authorization from the author or the Society.  
  43. ; * Software incorporating this module, all or in part, must be 
  44. ; * provided to the Society prior to distribution or use by
  45. ; * anyone not directly involved in testing of the revised  
  46. ; * environment.  Current releases of the combined software must
  47. ; * be provided to the Society in both source and executable
  48. ; * forms.  Adequate documention to produce an executable module 
  49. ; * from the provided source must also be included.
  50. ; *
  51. ; * Non-Amateur Radio non-profit uses may be authorized on a case
  52. ; * by case basis.  Inquiries for such use may be made in writing
  53. ; * to the Society. Non-commercial uses consistent with the
  54. ; * general principles of Open Systems Interconnection Reference
  55. ; * Model will be generally considered with favor.
  56. ; *
  57. ; * Commercial licensing of the software is also available based
  58. ; * on normal commercial terms.  Licensing inquiries should be
  59. ; * directed to the Society.  Commercial licensing of the standard
  60. ; * software will be done in situations which materially benefit
  61. ; * the Amateur Radio Packet Network.  Additional licensing is
  62. ; * reserved by the individual authors.
  63. ; * 
  64. ; * The Radio Amateur Telecommunications Society provides this software
  65. ; * on an "as is" basis.  The Society assumes no liability for
  66. ; * loss incurred through the use of this software.  Amateur Radio
  67. ; * use of this software implies non-commercial and voluntary 
  68. ; * development, deployment and use of this software in a "Amateur",
  69. ; * non-commercial service.  Commercial users are encouraged to
  70. ; * inspect their copies of the source code.  Source code modification
  71. ; * licenses are available if a combined Object and Source Code
  72. ; * license was not originally established.
  73. ; * 
  74. ; * The Society may be contacted by writing or calling at:
  75. ; * 
  76. ; * The Radio Amateur Telecommunications Society 
  77. ; * 206 North Vivyen Street.
  78. ; * Bergenfield, New Jersey 07621
  79. ; *
  80. ; * Telephone: 201-387-8896
  81. ; *
  82. ; */
  83. ;
  84. ; System Init for ROM
  85. ;
  86.     psect    text,pure
  87.  
  88. *INCLUDE RCONFIG.LIB
  89. *INCLUDE STRUCT.LIB
  90.  
  91. MSYNC    EQU    10H
  92. CTS    EQU    05H        ;SIO RR0 CTS Bit (Mask 20h)
  93. MDCD    EQU    08H
  94. MRTS    EQU    02H
  95.  
  96.     GLOBAL    CLKBIT, TICKCNT, HDLI
  97.  
  98. POWER_FAIL EQU    0150H
  99.  
  100.     psect    text
  101. start:    di            ;Insure NO int's!!
  102.     jp    POWER_FAIL    ;Power Failure, check memory, etc
  103.     jp    INIT_HDW    ;Set up SDS's based on the machine type
  104.     jp    INIT_LED    ;Init Led's
  105.     jp    UPD_LED        ;Change Led's (toggle)
  106.     HALT            ;Nothing to do when "halted"
  107.     RET
  108.     NOP
  109.  
  110.     global    amul, brelop, wrelop, csv, cret
  111.  
  112. RST2:    jp    (hl)        ;for optimizer    **********'0010'**************
  113.     defm    'TAPR   '
  114. RST3:    jp    amul        ;for optimizer    **********'0018'**************
  115.     defm    'TNC-2'
  116. RST4:    jp    brelop        ;for optimizer    **********'0020'**************
  117.     defm    'Clone'
  118. RST5:    jp    wrelop        ;for optimizer    **********'0028'**************
  119.     defm    'W2VY'
  120.     defb    0
  121. RST6:    jp    csv        ;for optimizer    **********'0030'**************
  122.     defm    'ROSE'
  123.     defb    0
  124. RST7:    ex    (sp),hl        ;for optimizer    **********'0038'**************
  125.     pop    hl
  126.     jp    cret
  127.  
  128. tickcnt: defb    12    ;600 Hz Tick
  129.     defw    0        ;Pointer to Terminal baud rate
  130.     defw    0        ;Pointer to Radio baud rate byte (SCCBI)
  131. ileds:    defb    0    ;Initial LED Pattern
  132.     defw    SDSI0, SDSI1
  133.  
  134.     global    SDS0, SDS1
  135.  
  136. INIT_HDW:    ;  Initialize the SIO data structures
  137.  
  138.     LD    HL,SDSI0    ;Copy from ROM
  139.     LD    DE,SDS0        ;To RAM
  140.     LD    BC,SDSILEN
  141.     LDIR
  142.  
  143.     LD    HL,SDSI1    ;Copy from ROM
  144.     LD    DE,SDS1        ;To RAM
  145.     LD    BC,SDSILEN
  146.     LDIR
  147.  
  148.     LD    A,MSYNC        ;Clock bit for TNC is SYNC
  149.     LD    (CLKBIT),A    ;Save it
  150.     LD    A,(tickcnt)    ;tick is at 1200 hz
  151.     LD    (TICKCNT),A    ;Number of Interrupts/Tick to 10 ms
  152.  
  153. ;    Radio Port PTT/DCD is always normal
  154.  
  155.     LD    HL,0FF02h    ;PTTMSK1=MRTS, PTTMSK2=FF
  156.     LD    (SDS0+PTTMSK1),HL
  157.     XOR    A
  158.     LD    B,A        ;DCD is Normal - No Toggle
  159.     LD    (SDS0+DCDTGL),A
  160.  
  161. ;    Is the async port on a NetRom back-to-back cable?
  162.  
  163.     LD    A,(SDS1+CPORT)    ;Async Port
  164.     LD    C,A        ;Port Address
  165.     IN    A,(C)        ;Get RR0 Status
  166.     BIT    CTS,A        ;CTS ON?
  167.     JR    NZ,1f        ;No, Don't Invert RTS and DCD
  168.     LD    HL,7D00h    ;PTTMSK1=00, PTTMSK2=~MRTS
  169.     LD    B,MDCD        ;Toggle DCD Bit
  170.     LD    A,(SDS1+WR5REG)
  171.     OR    MRTS        ;Set the Async PTT to the right idle State
  172.     LD    (SDS1+WR5REG),A
  173. 1:    LD    (SDS1+PTTMSK1),HL ;RTS Handling
  174.     LD    A,B          ;DCD Handling
  175.     LD    (SDS1+DCDTGL),A
  176.  
  177.     LD    IY,SDS0
  178.     CALL    HDLI
  179.     LD    IY,SDS1
  180.     CALL    HDLI
  181.  
  182.     RET
  183.  
  184. INIT_LED:
  185.     LD    D,5
  186.     LD    IY,SDS0        ;Get address of port 0
  187.     LD    C,(IY+CPORT)    ; CON Led
  188.     OUT    (C),D        ;WR 5
  189.     LD    A,B
  190.     AND    80h            ; CON Led is High Bit
  191.     LD    E,A
  192.     LD    A,(IY+WR5REG)    ;Get Current value
  193.     AND    7Fh        ;Ignore DTR
  194.     OR    E        ;Set DTR
  195.     OUT    (C),A
  196.     LD    IY,SDS1        ;Get to SDS1
  197.     LD    C,(IY+CPORT)    ; STA Led
  198.     OUT    (C),D        ;WR 5
  199.     LD    A,B
  200.     AND    40h        ;STA Led is second bit
  201.     SLA    A
  202.     LD    E,A
  203.     LD    A,(IY+WR5REG)
  204.     AND    7Fh        ;Ignore DTR
  205.     OR    E        ;Set DTR
  206.     OUT    (C),A        ;LEDS Now indicate Restart Cause
  207.     RET
  208.  
  209. UPD_LED:
  210.     call    csv
  211.     ld    hl,SDS0            ;Get to SDS0
  212.     call    toggle
  213.     ld    hl,SDS1            ;Get to SDS1
  214.     call    toggle
  215.     jp    cret
  216.  
  217. toggle:
  218.     ld    de,CPORT
  219.     add    hl,de
  220.     ld    c,(hl)        ;Get command port address
  221.     ld    de,WR5REG-CPORT
  222.     add    hl,de
  223.     ld    b,5        ;WR 5
  224.     DI
  225.     ld    a,(hl)
  226.     xor    80h
  227.     ld    (hl),a
  228.     out    (c),b
  229.     out    (c),a
  230.     EI
  231.     ret
  232.  
  233.     GLOBAL    SDSI0, SDSI1
  234. SDSI0:    DEFB    0        ;Channel number
  235.     DEFB    0DCh        ;SIO data port
  236.     DEFB    0DDh        ;SIO control port
  237.     DEFW    DWAIT0
  238.     DEFW    TXDELAY0
  239.     DEFW    SIOBI        ;SYNC CONFIG
  240.     DEFB    SIOBIL        ;LEN
  241.     DEFB    0        ;Flags
  242.     DEFB    0E9h        ;WR5REG (DTR Now On, CON)
  243.  
  244. SDSI1:    DEFB    1        ;Channel number
  245.     DEFB    0DEh        ;SIO data port
  246.     DEFB    0DFh        ;SIO control port
  247.     DEFW    DWAIT1
  248.     DEFW    TXDELAY1
  249.     DEFW    SIOAI        ;ASYNC CONFIG
  250.     DEFB    SIOAIL        ;LEN
  251.     DEFB    MASYNC+MTIMER+MAFT    ;ON A TNC2
  252.     DEFB    068h        ;WR5REG (DTR is Now Off, STA) RTS Off
  253.  
  254. ;  Fixed data
  255.  
  256. ;  SIO ASYNC initialization block.
  257.  
  258. SIOAI:    DEFB    18H        ;Reset SIO
  259.     DEFB    2,0        ;Set Up Interrupt Vector
  260.     DEFB    14h        ;WR 4 + Reset Ext Intr
  261.     DEFB    44H        ;16xClk + 1Stop
  262.     DEFB    3        ;WR 3
  263.     DEFB    0C1H        ;8bit + RxEnable
  264.     DEFB    5        ;WR 5
  265.     DEFB    068H        ;DTR Off + 8bit + TxEnable + RTS Off
  266.     DEFB    11h        ;WR 1 + Reset Ext intr
  267.     DEFB    00011111B     ;Enable rx, ext ints
  268. SIOAIL    EQU    $-SIOAI
  269.  
  270. ;  SIO SYNC initialization block.
  271.  
  272. SIOBI:    DEFB    18H        ;Reset SIO
  273.     DEFB    3        ;WR 3
  274.     DEFB    11011001B     ;8 bits, EnterHunt, RxCRC, RxEnable
  275.     DEFB    14h        ;WR 4 + Reset Ext Intr
  276.     DEFB    00100000B     ;SDLC mode, x1 clock
  277.     DEFB    5        ;WR 5
  278.     DEFB    01101001B     ;DTR off, RTS off
  279.     DEFB    7        ;WR 7
  280.     DEFB    01111110B     ;SDLC flag byte
  281.     DEFB    11h        ;WR 1 + Reset Ext Intr
  282.     DEFB    00011111B     ;Enable rx, ext ints
  283.     DEFB    10000000B    ;Reset Tx CRC
  284. SIOBIL    EQU    $-SIOBI
  285.  
  286.